/**
 * @file serial_device.h
 * @brief Code for XXX driver
 * @author He Shaohua (hsh15529870639@foxmail.com)
 * @date 2024-03-20
 * @version 1.0
 * @copyright Copyright (c) 2024, SNUT-Chaoyue Team
 * ****************************************************************************************************
 * @par Change Log:
 * <table>
 * <tr><th>Date         <th>Version       <th>Author      <th>Description
 * <tr><td>2024-03-20   <td> 1.0          <td>He Shaohua  <td>Creator
 *
 * </table>
 * ==================================----How to use this driver----=====================================
 * [..]
 * @note
 *   -#
 *
 * @warning
 *   -#
 *
 * *****************************************************************************************************
 * @attention
 *
 * This document is required and please understand any bugs that may occur in the document.
 * If you want to modify this file, after the code update is completed, update the version number in time,
 * indicate the update date, and fill in the changes
 * Make sure that the submitted code does not have many bugs.
 *
 * All rights reserved.
 * *****************************************************************************************************
 */
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __SERIAL_DEVICE_H
#define __SERIAL_DEVICE_H

/* Includes Header -----------------------------------------------------------*/

#include <string>
#include <stdlib.h>
#include <vector>
#include <rclcpp/rclcpp.hpp>
#include <serial/serial.h>
/* Private typedef -----------------------------------------------------------*/
typedef void (*Serial_RxCall)(uint8_t command, uint8_t *buffer, size_t size);

namespace ConnectDriver
{

  class Class_ConnectDriver
  {
  public:
    explicit Class_ConnectDriver(void (*Serial_RxCall)(uint8_t command, uint8_t *buffer, size_t size));
    virtual ~Class_ConnectDriver() = default;

    bool SetSerialPort(const std::string port_name, const uint32_t baudrate);
    bool Connect();
    void Disconnect();
    void Send(uint8_t *buffer, size_t size);
    void Receive();

  private:
    std::string _port_name;
    uint32_t _baudrate;
    serial::Serial connect;
    Serial_RxCall callback;
    uint8_t Rx_buffer[512];
  };
}

#endif /* __SERIAL_DEVICE_H */

/**
 * @}
 */

/**
 * @}
 */

/**
 * @}
 */
/*********************************END OF FILE*********************************/
